/*    */ package com.zimbra.cs.account.callback;
/*    */ 
/*    */ import com.zimbra.common.account.Key.DomainBy;
/*    */ import com.zimbra.common.account.ZAttrProvisioning.AutoProvMode;
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import com.zimbra.common.util.Log;
/*    */ import com.zimbra.common.util.ZimbraLog;
/*    */ import com.zimbra.cs.account.AccountServiceException;
/*    */ import com.zimbra.cs.account.AttributeCallback;
/*    */ import com.zimbra.cs.account.AttributeCallback.MultiValueMod;
/*    */ import com.zimbra.cs.account.AutoProvisionThread;
/*    */ import com.zimbra.cs.account.Domain;
/*    */ import com.zimbra.cs.account.Entry;
/*    */ import com.zimbra.cs.account.Provisioning;
/*    */ import com.zimbra.cs.account.Server;
/*    */ import com.zimbra.cs.util.Zimbra;
/*    */ import java.util.Map;
/*    */ import java.util.Set;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class AutoProvScheduledDomains
/*    */   extends AttributeCallback
/*    */ {
/*    */   public void preModify(CallbackContext context, String attrName, Object attrValue, Map attrsToModify, Entry entry)
/*    */     throws ServiceException
/*    */   {
/* 45 */     Provisioning prov = Provisioning.getInstance();
/*    */     
/* 47 */     AttributeCallback.MultiValueMod mod = multiValueMod(attrsToModify, "zimbraAutoProvScheduledDomains");
/* 48 */     if ((mod != null) && ((mod.adding()) || (mod.replacing()))) {
/* 49 */       for (String domainName : mod.valuesSet()) {
/* 50 */         Domain domain = prov.get(Key.DomainBy.name, domainName);
/* 51 */         if (domain == null) {
/* 52 */           throw AccountServiceException.NO_SUCH_DOMAIN(domainName);
/*    */         }
/*    */         
/* 55 */         if (!autoProvisionEnabled(domain)) {
/* 56 */           throw ServiceException.INVALID_REQUEST("EAGER auto provision is not enabled on domain " + domainName, null);
/*    */         }
/*    */       }
/*    */     }
/*    */   }
/*    */   
/*    */   private boolean autoProvisionEnabled(Domain domain)
/*    */   {
/* 64 */     return domain.getMultiAttrSet("zimbraAutoProvMode").contains(ZAttrProvisioning.AutoProvMode.EAGER.name());
/*    */   }
/*    */   
/*    */ 
/*    */ 
/*    */   public void postModify(CallbackContext context, String attrName, Entry entry)
/*    */   {
/* 71 */     if (!Zimbra.started()) {
/* 72 */       return;
/*    */     }
/*    */     try
/*    */     {
/* 76 */       if ((entry instanceof Server))
/*    */       {
/*    */ 
/* 79 */         if (!((Server)entry).isLocalServer()) {
/* 80 */           return;
/*    */         }
/*    */       }
/*    */     } catch (ServiceException e) {
/* 84 */       ZimbraLog.misc.warn("unable to validate server", e);
/* 85 */       return;
/*    */     }
/*    */     try
/*    */     {
/* 89 */       AutoProvisionThread.switchAutoProvThreadIfNecessary();
/*    */     } catch (ServiceException e) {
/* 91 */       ZimbraLog.autoprov.error("unable to switch auto provisioning thread", e);
/*    */     }
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/account/callback/AutoProvScheduledDomains.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */